home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 25 / AMIGAplus Sonderheft 25 (2000)(Falke)(DE)(Track 1 of 4)[!].iso / Updates / PowerPC / pdflib / bind / c / hello.c < prev    next >
C/C++ Source or Header  |  2000-05-16  |  933b  |  48 lines

  1. /* hello.c
  2.  *
  3.  * PDFlib client: hello example in C
  4.  *
  5.  */
  6.  
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9.  
  10. #include "pdflib.h"
  11.  
  12. int
  13. main(void)
  14. {
  15.     PDF *p;
  16.     int font;
  17.  
  18.     p = PDF_new();
  19.  
  20.     /* open new PDF file */
  21.     if (PDF_open_file(p, "hello_c.pdf") == -1) {
  22.     fprintf(stderr, "Error: cannot open PDF file hello_c.pdf.\n");
  23.     exit(2);
  24.     }
  25.  
  26.     PDF_set_info(p, "Creator", "hello.c");
  27.     PDF_set_info(p, "Author", "Thomas Merz");
  28.     PDF_set_info(p, "Title", "Hello, world (C)!");
  29.  
  30.     PDF_begin_page(p, a4_width, a4_height);    /* start a new page    */
  31.  
  32.     font = PDF_findfont(p, "Helvetica-Bold", "default", 0);
  33.     if (font == -1) {
  34.     fprintf(stderr, "Couldn't set font!\n");
  35.     exit(3);
  36.     }
  37.  
  38.     PDF_setfont(p, font, 24);
  39.     PDF_set_text_pos(p, 50, 700);
  40.     PDF_show(p, "Hello, world!");
  41.     PDF_continue_text(p, "(says C)");
  42.     PDF_end_page(p);                /* close page        */
  43.  
  44.     PDF_close(p);                /* close PDF document    */
  45.  
  46.     exit(0);
  47. }
  48.